import 'package:flutter/material.dart';
import 'package:flutter_chat/common/constant/constants.dart';
import 'package:flutter_chat/common/style/styles.dart';
import 'package:flutter_chat/common/widget/widgets.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';

import 'logic.dart';

class ChatUserInfoPage extends GetView<ChatUserInfoLogic> {
  ChatUserInfoPage({super.key});

  @override
  final String tag =
      "${RouterTag.chatUserInfo}${Get.parameters[RouterParam.chatId]}";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: customAppBar(
        "聊天信息",
      ),
      body: ListView(
        physics: const BouncingScrollPhysics(
          parent: AlwaysScrollableScrollPhysics(),
        ),
        children: [
          _buildUserList(),
          const Gap(AppTheme.largeSpace),
          CellWidget(
            right: GestureDetector(
              onTap: () {},
              child: const Icon(
                Icons.chevron_right,
                color: AppTheme.minorColor,
              ),
            ),
            title: "设置当前聊天背景",
          ),
        ],
      ),
    );
  }

  Container _buildUserList() {
    return Container(
      color: Colors.white,
      padding: const EdgeInsets.all(AppTheme.largeSpace),
      child: GridView(
        physics: const NeverScrollableScrollPhysics(), // 禁止滚动
        shrinkWrap: true,
        gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
          crossAxisCount: 5,
          crossAxisSpacing: AppTheme.largeSpace,
          mainAxisSpacing: AppTheme.largeSpace,
          childAspectRatio: 0.9,
        ),
        children: [
          /// 用户
          const Column(
            children: [
              ImageWidget(
                "http://q1.qlogo.cn/g?b=qq&nk=3355691290&s=640",
                size: 55,
                radius: AppTheme.radius,
              ),
              SizedBox(
                width: 60,
                child: Text(
                  "今天比昨天更爱你",
                  style: TextStyle(
                    fontSize: AppTheme.smallFont,
                  ),
                  overflow: TextOverflow.ellipsis,
                ),
              ),
            ],
          ),

          /// 邀请用户
          Column(
            children: [
              Container(
                width: 55,
                height: 55,
                decoration: BoxDecoration(
                  border: Border.all(
                    color: AppTheme.minorColor,
                    width: 2,
                    style: BorderStyle.solid,
                  ),
                  borderRadius: BorderRadius.circular(AppTheme.radius),
                ),
                child: IconButton(
                  onPressed: () {},
                  icon: const Icon(
                    Icons.add,
                    size: 30,
                    color: AppTheme.minorColor,
                  ),
                ),
              ),
            ],
          ),

          /// 移除用户
          Column(
            children: [
              Container(
                width: 55,
                height: 55,
                decoration: BoxDecoration(
                  border: Border.all(
                    color: AppTheme.minorColor,
                    width: 2,
                    style: BorderStyle.solid,
                  ),
                  borderRadius: BorderRadius.circular(AppTheme.radius),
                ),
                child: IconButton(
                  onPressed: () {},
                  icon: const Icon(
                    Icons.remove,
                    size: 30,
                    color: AppTheme.minorColor,
                  ),
                ),
              ),
            ],
          )
        ],
      ),
    );
  }
}
